home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -serious- / programming / other / tandem / teaching / 66.asm < prev    next >
Assembly Source File  |  1999-09-06  |  6KB  |  304 lines

  1. * 66.asm     TLslimon      0.01    8.6.99)
  2.  
  3.  
  4.  include 'Front.i'
  5.  
  6.  
  7. ; *** Important!!! ***
  8. ;
  9. ; If assembling this program for demonstration/77, make the
  10. ; address of  Logo.iff  to be  /Logo.iff  in string 12
  11.  
  12.  
  13. ; See the remarks on 65.asm, which are also pertinent to this program
  14.  
  15.  
  16. vert: ds.l 1                ;xxp_tops cache for vert,horz sliders
  17. horz: ds.l 1
  18.  
  19. logo: ds.l 1                ;pointer to bitmap where Logo.iff stored
  20.  
  21.  
  22. strings: dc.b 0
  23. st_1: dc.b  'TLSlimon demonstration',0 ;1
  24.  dc.b 'Out of chip ram',0 ;2
  25.  dc.b 'totl 298',0 ;3
  26.  dc.b 'strs 64',0 ;4
  27.  dc.b 'tops',0 ;5
  28.  dc.b 'Horz',0 ;6
  29.  dc.b 'Vert',0 ;7
  30.  dc.b 'totl 149',0 ;8
  31.  dc.b 'strs 48',0 ;9
  32.  dc.b 'Error: can''t find/load Tandem/Logo.iff',0 ;10
  33.  dc.b 'Use the sliders to move the logo around...',0 ;11
  34.  dc.b 'Logo.iff',0 ;12
  35.  
  36.  ds.w 0
  37.  
  38.  
  39. Program:
  40.  TLwindow #0,#0,#0,#200,#100,#640,#256,#0,#st_1
  41.  beq Pr_bad1
  42.  
  43.  TLstrbuf #12
  44.  move.l a4,a1
  45.  add.w #20,a1
  46.  TLgetilbm #2,a1
  47.  beq Pr_bad2
  48.  move.l a0,logo
  49.  
  50.  clr.l vert                ;init vert,horz
  51.  clr.l horz
  52.  
  53. Pr_draw:
  54.  bsr Logo                  ;update the window, display the logo
  55.  
  56.  move.l xxp_AcWind(a4),a5
  57.  move.w #$0200,xxp_FrontPen(a5)
  58.  TLstring #11,#20,#6
  59.  subq.b #1,xxp_FrontPen(a5)
  60.  
  61.  TLreqbev #20,#20,#320,#161     ;outline bev: scrolling area 22-319 X 21-169
  62.  
  63.  TLreqarea #320,#170,#18,#10,#3 ;draw icon at bottom right
  64.  TLreqbev #320,#170,#20,#11
  65.  TLpict #11,#326,#171
  66.  
  67.  TLstring #6,#400,#20      ;print horz data: totl, strs, tops stub
  68.  TLstring #3,#448,#20
  69.  TLstring #4,#448,#28
  70.  TLstring #5,#448,#36
  71.  
  72.  TLstring #7,#400,#52      ;print vert data:  totl, strs, tops stub
  73.  TLstring #8,#448,#52
  74.  TLstring #9,#448,#60
  75.  TLstring #5,#448,#68
  76.  
  77.  move.l #20,xxp_slix(a4)   ;draw horz slider
  78.  move.l #170,xxp_sliy(a4)
  79.  move.l #300,xxp_sliw(a4)
  80.  move.l #11,xxp_slih(a4)
  81.  move.l #298,xxp_totl(a4)
  82.  move.l #64,xxp_strs(a4)
  83.  move.l horz,xxp_tops(a4)
  84.  TLslider xxp_AcWind(a4),a5
  85.  
  86.  move.l #320,xxp_slix(a4)  ;draw vert slider
  87.  move.l #20,xxp_sliy(a4)
  88.  move.l #20,xxp_sliw(a4)
  89.  move.l #150,xxp_slih(a4)
  90.  move.l #149,xxp_totl(a4)
  91.  move.l #48,xxp_strs(a4)
  92.  move.l vert,xxp_tops(a4)
  93.  clr.l xxp_hook(a4)
  94.  TLslider xxp_AcWind(a4),a5
  95.  
  96.  bsr Htops                 ;print horz tops value
  97.  bsr Vtops                 ;print vert tops value
  98.  
  99. Pr_wait:                   ;* wait for keyboard input
  100.  TLwcheck
  101.  bne Pr_draw               ;go redraw all if window resized
  102.  
  103.  TLkeyboard
  104.  cmp.b #$93,d0             ;quit if close window
  105.  beq Pr_quit
  106.  cmp.b #$1B,d0             ;quit if Esc
  107.  beq Pr_quit
  108.  
  109.  cmp.b #$80,d0             ;ignore keyboard input unless lmb click
  110.  bne Pr_wait
  111.  
  112.  move.l horz,xxp_tops(a4)  ;monitor horz slider
  113.  move.l #20,xxp_slix(a4)
  114.  move.l #170,xxp_sliy(a4)
  115.  move.l #300,xxp_sliw(a4)
  116.  move.l #11,xxp_slih(a4)
  117.  move.l #298,xxp_totl(a4)
  118.  move.l #64,xxp_strs(a4)
  119.  move.l #Hhook,xxp_hook(a4)
  120.  TLslimon d1,d2,d3
  121.  beq.s Pr_vert             ;go if horz slider inactive
  122.  move.l xxp_tops(a4),horz  ;else update horz
  123.  bra Pr_wait               ;& get next keyboard input
  124.  
  125. Pr_vert:
  126.  move.l vert,xxp_tops(a4)  ;monitor vert slider
  127.  move.l #320,xxp_slix(a4)
  128.  move.l #20,xxp_sliy(a4)
  129.  move.l #20,xxp_sliw(a4)
  130.  move.l #150,xxp_slih(a4)
  131.  move.l #149,xxp_totl(a4)
  132.  move.l #48,xxp_strs(a4)
  133.  move.l #Vhook,xxp_hook(a4)
  134.  TLslimon d1,d2,d3
  135.  beq Pr_wait               ;go if vert slider inactive
  136.  move.l xxp_tops(a4),vert  ;else update vert
  137.  bra Pr_wait               ;& get keyboard input
  138.  
  139. Pr_bad1:                   ;report out of mem if bad
  140.  TLbad #2
  141.  bra.s Pr_quit
  142.  
  143. Pr_bad2:
  144.  TLbad #10
  145.  
  146. Pr_quit:                   ;exit from Program
  147.  tst.l logo
  148.  beq.s Pr_exit
  149.  TLfreebmap logo           ;free logo memory
  150. Pr_exit:
  151.  rts
  152.  
  153.  
  154. * hook for horizontal slider
  155. Hhook:
  156.  bsr Htops
  157.  bsr Hlogo
  158.  rts
  159.  
  160.  
  161. * show horz tops
  162. Htops:
  163.  move.l #'    ',(a4)
  164.  TLhexasc xxp_tops(a4),a4
  165.  clr.b 3(a4)
  166.  TLtrim #488,#36
  167.  rts
  168.  
  169.  
  170. * hook for vertical slider
  171. Vhook:
  172.  bsr Vtops
  173.  bsr Vlogo
  174.  rts
  175.  
  176.  
  177. * move the logo horizontally
  178. Hlogo:
  179.  move.l xxp_gfxb(a4),a6
  180.  move.l xxp_AcWind(a4),a5
  181.  
  182.  move.l xxp_WPort(a5),a1
  183.  moveq #3,d0
  184.  jsr _LVOSetBPen(a6)
  185.  
  186.  move.l xxp_WPort(a5),a1
  187.  moveq #22,d2
  188.  moveq #21,d3
  189.  move.l #319,d4
  190.  cmp.w xxp_PWidth(a5),d4
  191.  ble.s Hl_vtrm
  192.  move.w xxp_PWidth(a5),d4
  193. Hl_vtrm:
  194.  move.l #169,d5
  195.  cmp.w xxp_PHeight(a5),d5
  196.  ble.s Hl_redi
  197.  move.w xxp_PHeight(a5),d5
  198. Hl_redi:
  199.  move.l horz,d0
  200.  sub.l xxp_tops(a4),d0
  201.  move.l xxp_tops(a4),horz
  202.  moveq #0,d1
  203.  add.w xxp_LeftEdge(a5),d2
  204.  add.w xxp_TopEdge(a5),d3
  205.  add.w xxp_LeftEdge(a5),d4
  206.  add.w xxp_TopEdge(a5),d5
  207.  TLwcheck
  208.  bne.s Hl_quit
  209.  jsr _LVOScrollRaster(a6)
  210. Hl_quit:
  211.  rts
  212.  
  213.  
  214. * move the logo vetically
  215. Vlogo:
  216.  move.l xxp_gfxb(a4),a6
  217.  move.l xxp_AcWind(a4),a5
  218.  
  219.  move.l xxp_WPort(a5),a1
  220.  moveq #3,d0
  221.  jsr _LVOSetBPen(a6)
  222.  
  223.  move.l xxp_WPort(a5),a1
  224.  moveq #22,d2
  225.  moveq #21,d3
  226.  move.l #319,d4
  227.  cmp.w xxp_PWidth(a5),d4
  228.  ble.s Vl_vtrm
  229.  move.w xxp_PWidth(a5),d4
  230. Vl_vtrm:
  231.  move.l #169,d5
  232.  cmp.w xxp_PHeight(a5),d5
  233.  ble.s Vl_redi
  234.  move.w xxp_PHeight(a5),d5
  235. Vl_redi:
  236.  moveq #0,d0
  237.  move.l vert,d1
  238.  sub.l xxp_tops(a4),d1
  239.  move.l xxp_tops(a4),vert
  240.  add.w xxp_LeftEdge(a5),d2
  241.  add.w xxp_TopEdge(a5),d3
  242.  add.w xxp_LeftEdge(a5),d4
  243.  add.w xxp_TopEdge(a5),d5
  244.  TLwcheck
  245.  bne.s Vl_quit
  246.  jsr _LVOScrollRaster(a6)
  247. Vl_quit:
  248.  rts
  249.  
  250.  
  251. * show vert tops
  252. Vtops:
  253.  move.l #'    ',(a4)
  254.  TLhexasc xxp_tops(a4),a4
  255.  clr.b 3(a4)
  256.  TLtrim #488,#68
  257.  rts
  258.  
  259.  
  260. * draw logo on the window (calls Wupdate)
  261. ; caution: the minumum size of the window must allow logo to fit at topleft
  262.  
  263. Logo:
  264.  TLwupdate
  265.  TLreqarea #22,#21,#298,#149,#3 ;fill scrolling area with pen 3
  266.  move.l xxp_AcWind(a4),a5  ;a5 = currently active window
  267.  
  268.  move.w xxp_PWidth(a5),d0  ;move horz if it doesn't fit on the window
  269.  sub.w #22,d0
  270.  sub.w #64,d0
  271.  cmp.w horz+2,d0
  272.  bcc.s Lo_vert
  273.  move.w d0,horz+2
  274.  
  275. Lo_vert:                   ;move vert if it doesn't fit on the window
  276.  move.w xxp_PHeight(a5),d0
  277.  sub.w #21,d0
  278.  sub.w #48,d0
  279.  cmp.w vert+2,d0
  280.  bcc.s Lo_redi
  281.  move.w d0,vert+2
  282.  
  283. Lo_redi:                   ;ready the blit
  284.  move.l logo,a0
  285.  move.l xxp_WPort(a5),a1
  286.  move.l xxp_gfxb(a4),a6
  287.  moveq #0,d0
  288.  moveq #0,d1
  289.  moveq #22,d2
  290.  add.w horz+2,d2
  291.  add.w xxp_LeftEdge(a5),d2
  292.  moveq #21,d3
  293.  add.w vert+2,d3
  294.  add.w xxp_TopEdge(a5),d3
  295.  moveq #64,d4
  296.  moveq #48,d5
  297.  move.w #$C0,d6
  298.  
  299.  TLwcheck                  ;recyle if window resized
  300.  bne Logo
  301.  
  302.  jsr _LVOBltBitMapRastPort(a6) ;go the blit
  303.  rts
  304.